<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../common/taglibs.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <title>xxxx管理平台</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${ctxLayui}/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${ctxLayui}/layuiadmin/style/login10/login.css" media="all">
  <style>
    .layui-form-checkbox span{
      height:20px;
    }
  </style>
  <script >
      if(window.top != window.self){
          top.location.href = location.href;
      }
  </script>

</head>
<body>
<div class="login_box layui-form" >
  <div class="login_l_img"><img src="${ctxLayui}/layuiadmin/style/login10/images/login-img.png" /></div>
  <div class="login">
    <div class="login_logo"><a href="#"><img src="${ctxLayui}/layuiadmin/style/login10/images/login_logo.png" /></a></div>
    <div class="login_name">
      <p><span class="businessName">xxxx管理平台</span></p>
    </div>
    <input name="userName" placeholder="用户名" autocomplete="off" lay-verify="required" type="text"  value="" >
    <input name="password" placeholder="密码" autocomplete="off" lay-verify="required" type="password" id="password" style="margin-bottom:1px;" />
    <div class="layui-form-item" style="margin-bottom: 5px;size: 12px;">
      <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住密码">
    </div>
    <button style="width:100%;" type="submit" lay-submit lay-filter="LAY-user-login-submit" id="loginBtn">
      登录
      <i class="layui-icon layui-icon-loading" style="display: none;" ></i>
    </button>

  </div>
</div>
<div style="text-align:center;">
</div>

<script src="${ctxLayui}/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxLayui}/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,router = layui.router()
            ,search = router.search;

        form.render();

        //提交
        form.on('submit(LAY-user-login-submit)', function(obj){

            //请求登入接口
            admin.req({
                url: ctx+layui.setter.loginActionUrl,
                data: obj.field,
                done: function(res){
                    var success = res.success;
                    if(success){
                        //请求成功后，写入 access_token
                        layui.data(setter.tableName, {
                            key: setter.request.tokenName,
                            value: res.data.access_token
                        });
                        layui.data(setter.tableName, {key:setter.userKey,value:res.data.user});
                        //登入成功的提示与跳转
                        layer.msg('登入成功', {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            location.href = ctx+layui.setter.indexPageUrl; //后台主页
                        });
                    }else{
                        var msg = res.msg;
                        layer.msg(msg, {
                            offset: '15px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                }
            });

        });

        $("#password").keydown(function (e) {
            if (e.keyCode === 13) {
                $("#loginBtn").trigger("click");
            }
        });
    });
</script>
</body>
</html>